#include <iostream>

class Person
{
public:
    int age;
    Person() : age(0)
    {
    }
    Person(int age) : age(age) {}
};

#if 0
bool operator<(const Person &p1, const Person &p2)
{
    return p1.age < p2.age;
}

bool operator>(const Person &p1, const Person &p2)
{
    return p1.age > p2.age;
}

#endif

template <typename T>
int compare(const T &t1, const T &t2)
{
    if (t1 > t2)
    {
        return 1;
    }
    else if (t1 < t2)
    {
        return -1;
    }
    else
    {
        return 0;
    }
}
// 模板特化的实现，必须先有一个模板
template <>
int compare<Person>(const Person &p1, const Person &p2)
{
    if (p1.age > p2.age)
    {
        return 1;
    }
    else if (p1.age < p2.age)
    {
        return -1;
    }
    else
    {
        return 0;
    }
}

int main(int argc, char const *argv[])
{
    
    // int a = 10;
    // int b = 100;
    // std::cout << compare(a, b) << std::endl;

    // Person p1{100};
    // Person p2{99};

    // std::cout << compare(p1, p2) << std::endl;

    return 0;
}
